home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: presby.edu!jtbell
- From: jtbell@presby.edu (Jon Bell)
- Subject: Re: Initializing each element in an array of classes
- Message-ID: <Do1A90.33L@presby.edu>
- Date: Sun, 10 Mar 1996 04:10:11 GMT
- References: <4hssvm$178_001@basmith1.iquest.net>
- Organization: Presbyterian College, Clinton, South Carolina USA
-
- Brian Smith <basmith@iquest.net> wrote:
- >class Dot {
- > int X;
- > int Y;
- > Dot(void);
- > Dot(int InitX, int InitY, int InitSize = 1) // default for InitSize is 1
- >};
-
- >class Box {
- > int i;
- > int j;
- > Dot DotArray[3];
- > etc...
- >}
-
- >How can I create this array of Dots with the X and Y values of, for example,
- >(1,1), (2,2), and (3,3)? The Borland Turbo C++ manual is of no help at all.
-
- Perhaps by writing a constructor for class Box, which takes either six
- ints or three Dots as arguments, and stuffs their values into DotArray?
- Sort of like your constructor for Dot? Or am I missing something here?
-
- --
- Jon Bell <jtbell@presby.edu> Presbyterian College
- Dept. of Physics and Computer Science Clinton, South Carolina USA
-